package daily.kou2022_0104;

public class Num160 {
    //160. 相交链表
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode pA = headA;
        ListNode pB = headB;
        // 1.相交时刚好返回交点
        // 2.不相交两个同时走到null
        while (pA != pB) {
            pA = pA == null ? headB : pA.next;
            pB = pB == null ? headA : pB.next;
        }
        return pA;
    }
}
